<template>
  <el-form v-bind="$attrs"
           ref="form">
    <el-form-item label=""
                  prop="signDesc">
      <el-input type="textarea"
                maxlength="200"
                show-word-limit
                :value="sign.signDesc"
                @input="handleInput('signDesc', arguments[0])" />
    </el-form-item>
  </el-form>
</template>
<script>
import _ from "lodash";
export default {
  name: "SignForm",
  props: ["value"],
  inheritAttrs: true,
  data () {
    return { sign: {} };
  },
  computed: {
    source () {
      return this.value || {};
    }
  },
  methods: {
    createData () {
      this.sign = { ...this.source };
    },
    debounceInput: _.debounce(function () {
      this.$emit("input", { ...this.source, ...this.sign });
    }, 100),
    handleInput (name, value) {
      this.sign[name] = value.trim();
      this.debounceInput();
    },
    validate () {
      return this.$refs.form.validate();
    }
  },
  watch: {
    value () {
      this.createData();
    }
  }
};
</script>
